<?php
class page extends Controller {

    function page(){
        parent::Controller();    
    }
    
    function index(){
        if($this->config->item('enable_query_strings'))
            $module = @trim($_GET[$this->config->item('module_trigger')]);
        else
            $module = $this->uri->segment(1);
        if(empty($module))
            $module = 'home';        
        $data['module_content'] = $this->modules->run($module, TRUE);
        
        $CI = & get_instance();
        if($CI->use_global_template)
            $this->parser->parse(FRONT_SITE.'/layout', $data);
        else
            echo $data['module_content'];
    }
    //http://localhost/timkhoahoc/?m=ajax&c=page&fid=1&mod=contents
    function ajax(){
        if($this->config->item('enable_query_strings'))
            $module = @trim($_GET[$this->config->item('module_trigger')]);
        else
            $module = $this->uri->segment(2);
        if(empty($module))
            $module = 'home';

        echo $data['module_content'] = $this->modules->run($module, TRUE);
    }
    
    function admin(){
        $module = $this->uri->segment(2);
        if(!$module)
            $module = 'home.login';
        $data['module_content'] = $this->modules->run($module, TRUE);
        $CI = & get_instance();
        if($CI->use_global_template)
            $this->parser->parse(ADMIN_SITE.'/layout', $data);
        else
            echo $data['module_content'];
    }
    
    function admin_ajax(){
        $this->modules->run('', FALSE);
    }
    
    function client(){
        $module = $this->uri->segment(2);
        if(!$module)
            $module = 'home.login';
        $data['module_content'] = $this->modules->run($module, TRUE);
        $CI = & get_instance();
        if($CI->use_global_template)
            $this->parser->parse(ADMIN_SITE.'/layout', $data);
        else
            echo $data['module_content'];
    }
    
    function client_ajax(){
        $this->modules->run('');
    }
}